
/**
 * 
 */

/**
 * @author Michael Fildestine ID:309161594
 *
 */

public class SuperSnowflake {

	private Snowflake flake;
	
	
	public SuperSnowflake(){
		this.flake = new Snowflake();				//initiating the flake field
	}
	
	public void draw(){
		int height =   Painter.getFrameHeight()/2;
		int width = Painter.getFrameWidth()/2;
		int maxRadius = Math.min(height, width)/2;
		int radius = maxRadius/4;
		Pixel p = new Pixel(height, width);
		Painter.setColor("blue");
//		flake.draw();
		draw(p, radius, 4, 3*radius);
	}
	
	private void draw(Pixel p, int radius, int depth, int circleRadius,double theta){		//private method that draws all flakes on the same line (with the same theta)
		
		if (depth > 1){
			double xCoord = 0;
			double yCoord = 0;
			
			xCoord = p.getX() + Math.cos(theta)*circleRadius;								//calculate x and y coordinates for next point
			yCoord = p.getY() + Math.sin(theta)*circleRadius;
			
			Pixel auxPixel = new Pixel((int)xCoord,(int)yCoord);							//Auxiliary pixel
			this.draw(auxPixel, radius/2, depth - 1, 3*radius,theta);						
			flake.draw(p, radius, depth);													//draws current flake.
		}
									
		
		
		
	}
	
	
	public void draw(Pixel p, int radius, int depth, int circleRadius){
		double theta = 0;
		double xCoord = 0;
		double yCoord = 0;
		
			flake.draw(p, radius, depth);														//draws center flake.
			for(int i = 0 ; i < 6 ; i++){
				xCoord = p.getX() + Math.cos(theta)*circleRadius;								//calculate x and y coordinates for next point
				yCoord = p.getY() + Math.sin(theta)*circleRadius;
				
				Pixel auxPixel = new Pixel((int)xCoord,(int)yCoord);							//an auxiliary pixel for the recursion
				this.draw(auxPixel, radius/2, depth, 3*radius,theta);							//draws all flakes that supposed to be in a same line. 
												
				theta = theta + 2*(Math.PI/6);
			}
	
		}
	
	
}
